import java.util.concurrent.Semaphore;

/**
 * Creat by TanLei
 * Description:
 * User:86183
 * Date:2022-06-16
 * Time:13:51
 */
public class Test4 {
    public static void main(String[] args) throws InterruptedException {
        Semaphore semaphore = new Semaphore(3);
        //P操作
        semaphore.acquire();
        System.out.println("P操作成功！");
        semaphore.acquire();
        System.out.println("P操作成功！");
        semaphore.acquire();
        System.out.println("P操作成功！");
        semaphore.acquire();
        System.out.println("P操作成功！");

        //V操作
        semaphore.release();
        System.out.println("V操作成功");

    }
}
